1. Field of the Invention
The present invention relates to an apparatus, a method and a computer program for arithmetic processing and, in particular, to an apparatus, a method and a computer program for performing accurately a power calculation.
2. Description of the Related Art
Moving picture expert group (MPEG) audio standard is known as a standard defining a method of encoding an audio signal. A plurality of encoding methods are defined by the MPEG standard. MPEG-2 Audio Standard Advanced Audio Coding (AAC) is standardized as the International Organization for Standardization/International Electrotechnical Commission (ISO/IEC) 13818-7.
MPEG-4 Audio Standard AAC encoding method is standardized as extended ISO/IEC 14496-3. In the discussion that follows, the MPEG-2 Audio Standard AAC and the MPEG-4 Audio Standard AAC are collectively referred to as the AAC Standards.
FIG. 1 illustrates an encoder in the related art complying with the AAC Standards.
The encoder includes speech reception and hearing model storage 11, gain controller 12, spectrum processor 13, quantizer/encoding unit 14, and multiplexer 15.
An audio signal input to the encoder is supplied to both the speech reception and hearing model storage 11 and the gain controller 12. The speech reception and hearing model storage 11 organizes the input signal into blocks along the time axis, analyzes the blocked audio signal on a per split band in accordance with human hearing characteristics, and then calculates a permissible error intensity of each split band.
The gain controller 12, used for a scalable sampling rate (SSR) profile only, splits the supplied audio signal into four equally spaced frequency bands, and adjusts gain of the bands other than the lowest frequency band.
The spectrum processor 13 converts the audio signal gain-adjusted by the gain controller 12 into spectral data. The spectrum processor 13 also controls each element thereof in response to the permissible error intensity supplied from the speech reception and hearing model storage 11, thereby performing a predetermined process on the spectral data.
The spectrum processor 13 includes modified discrete cosine transform (MDCT) unit 21, temporal noise shaping (TNS) processing unit 22, intensity coupler 23, predictor 24, and middle/side (M/S) stereo unit 25.
The MDCT unit 21 converts the audio signal in the time domain supplied from the gain controller 12 into spectral data in the frequency domain. The TNS processing unit 22 processes the spectral data, into which the MDCT unit 21 has converted the audio signal. The TNS processing unit 22 thus adjusts the temporal shape of quantization noise. The intensity coupler 23 performs a joint stereo encoding process on the audio signal processed by the TNS processing unit 22.
The predictor 24 performs a prediction encoding process on the audio signal joint stereo encoded by the intensity coupler 23 and the audio signal supplied by a quantizer 27. The predictor 24 then supplies the resulting audio signal to the M/S stereo unit 25. The M/S stereo unit 25 joint-stereo-encodes the audio signal from the predictor 24 and supplies the resulting audio signal to the quantizer/encoding unit 14.
The quantizer/encoding unit 14 converts the audio signal from the M/S stereo unit 25 into a code sequence, and then supplies the code sequence to the multiplexer 15. The quantizer/encoding unit 14 includes normalized coefficient unit 26, quantizer 27, and Huffman coder 28.
The normalized coefficient unit 26 then supplies the audio signal from the M/S stereo unit 25 to the quantizer 27. The normalized coefficient unit 26 also calculates a normalized coefficient for use in the quantization of the audio signal in response to the audio signal from the M/S stereo unit 25, and then supplies the normalized coefficient to each of the quantizer 27 and the Huffman coder 28. For example, the normalized coefficient unit 26 calculates a quantization step parameter as the normalized coefficient for each split band using the permissible error intensity from the speech reception and hearing model storage 11.
The quantizer 27 non-linear quantizes the audio signal from the normalized coefficient unit 26 using the normalized coefficient from the normalized coefficient unit 26. The quantizer 27 supplies the resulting audio signal (a quantized value) to each of the Huffman coder 28 and the predictor 24. In accordance with a predetermined Huffman code table, the Huffman coder 28 imparts a Huffman code to each of the normalized coefficient from the normalized coefficient unit 26 and the quantized value from the quantizer 27, thereby Huffman encoding the normalized coefficient and the quantized value. The Huffman encoded normalized coefficient and quantized value are thus supplied to the multiplexer 15.
The multiplexer 15 multiplexes the Huffman code supplied from the Huffman coder 28 and a variety of information generated in the course of encoding of the audio signal, supplied by the gain controller 12, and the MDCT unit 21 through the normalized coefficient unit 26. The multiplexer 15 thus generates and outputs a bit stream of the encoded audio signal.
The quantizer 27 performs the non-linear quantization process on the audio signal by calculating the following equation (1) in response to an input value AX as the value of the audio signal from the normalized coefficient unit 26 and a quantization step parameter q as the normalized coefficient from the normalized coefficient unit 26. More specifically, a quantized value RZ is determined from the input value AX of the audio signal in accordance with equation (1):
                    RZ        =                              (            int            )                    ⁢                      (                                                            (                                      AX                                          2                                              q                        /                        4                                                                              )                                                  3                  /                  4                                            -              0.0946              +              0.5                        )                                              (        1        )            where (int)(A) represents an operation that results in an integer part of a floating-point number A by rounding down a fraction portion. The same is true in the discussion that follows.
In the encoding of the AAC Standards, the quantized value RZ is defined as 14 bits. A reverse operation shows that a value AY=AX/2q/4 prior to the quantization has a range of 0≦AY<8191.5943(4/3). The quantized value RZ is an integer falling within the range of 0≦RZ≦8191. The quantization step parameter q is determined so that the quantized value RZ falls within this range.
During the quantization of the audio signal, the quantizer 27 dequantizes the quantized values RZ of all the input values AX, and determines whether each quantization error falls within a predetermined range. For example, the dequantization is performed in accordance with the following equation (2), and a dequantized value W is thus obtained:W=(RZ)4/3  (2)
The quantization error is determined by determining a difference between the dequantized value W and the input value AX. It is thus determined whether the difference falls within the predetermined range.
A method of efficiently obtaining results of a power operation to the power of 3/4 in equation (1) or a power operation to the power of 4/3 in equation (2) is disclosed (Japanese Unexamined Patent Application Publication No. 2001-5643). In accordance with the disclosure, an input value X as a floating-point number is split into an exponent and a mantissa, and a logarithmic value Z with respect to a base 2 of an arithmetic value P that is obtained by raising the input value X to the power of Y is determined. The logarithmic value Z is then expressed back to the sought arithmetic value P using the power of 2. The power operation result of the input value X is thus obtained.
In accordance with the disclosure, the power operation is performed as described below. A particular process is performed if the base is Napier's constant or a multiple of 2. A general process other than the particular process for such bases is described below.
Let P represent an arithmetic value P as the result of the power operation of raising the input value X to the power of Y, the following equation (3) holds:P=XY  (3)
The input value X is split into a mantissa X1 as a mantissa part of the floating-point number and an exponent X2 as an exponent part of the floating-point number, and the power operation of the input value X to the power Y is then considered.
The floating-point number is described first. Data of floating-point type indicating a single precision floating-point type number based on the Institute for Electrical and Electronics Engineering (IEEE) 754 Standard is constructed of a 32-bit bit sequence as illustrated in FIG. 2.
A 23-bit portion from zero-th bit as the least significant bit of the data of the floating-point number to 22nd bit is a mantissa X1 as a mantissa part of the floating-point number. An 8-bit portion from 23rd bit to 30th bit is an exponent X2 of an exponent part of the floating-point number. The most significant bit as the 31st bit is a sign bit S.
The sign bit S is “0” if the mantissa part is positive, and is “1” if the mantissa part is negative. The bit structure of the exponent part is “an exponent+bias.” The exponent X2 as the exponent part is the sum of an actual exponent value and a bias. In accordance with the IEEE754 Standard, 127 is used as a single precision bias. If the exponent value is “0,” the exponent X2 is “127” (=0+127). The exponent part has a bit structure of 127, namely, 0x7f. Here 0x means that “7f” is a hexadecimal number.
The exponent part of 0 or 255 has a particular meaning, but the discussion thereof is omitted here.
If the input value X of floating-point type data is represented in a numerical form, the input value X is represented as in the following equation (4):(−1)S×2(X2−B)×(1+.X1)=(−1)S×2(X2−B)×(1+X1/223)  (4)where “.X1” represents a mantissa part with a decimal point on the premise that the decimal point is placed prior to an upper bit of the mantissa X1. Also in equation (4), “B” represents a bias component and “S” represents a sign bit.
In accordance with Japanese Unexamined Patent Application Publication No. 2001-5643, the input value X as the floating-point number is split into the mantissa X1 and the exponent X2 before the power operation.
Let X1 represent a mantissa of the mantissa part of the input value X and X2 represent an exponent of the exponent part of the input value X, and the input value X is represented by equation (5):X=(1+X1/223)×2X2  (5)
If the logarithm of base 2 is calculated to both sides of equation (3), equation (6) holds:Z=log2P=Y{X2+log2(1+X1/223)}  (6)
Let Zint represent an integer part of the logarithmic value Z and Zamari represent a fraction part of the logarithmic value Z, and the arithmetic value P is represented by the following equation (7):
                                                        P              =                              2                                                      log                    2                                    ⁢                  P                                                                                                        =                              2                Z                                                                                        =                                                2                                      Z                    amari                                                  ×                                  2                                      Z                    int                                                                                                          (        7        )            
The integer Zint and the fraction Zamari in equation (7) are determined from equation (6). From equations (6) and (7), the arithmetic value P resulting from raising the input value X to the power of Y is thus determined.
A quantizing apparatus 51 that quantizes the audio signal by performing the power operation in this way is illustrated in FIG. 3.
The quantizing apparatus 51 corresponds to the quantizer 27 illustrated in FIG. 1. The quantizing apparatus 51 receives a value AY prior to quantization as the input value X and a power exponent Y=¾ in equation (1).
A mantissa-exponent splitter 61 splits the supplied input value X into the mantissa X1 and the exponent X2, and then supplies the mantissa X1 and the exponent X2 to the logarithmic calculator 62. A logarithmic calculator 62 receives a power exponent Y. The logarithmic calculator 62 then calculates equation (6) in response to the mantissa X1 and the exponent X2, supplied from the mantissa/exponent splitter 61, and the supplied power exponent Y, thereby determining a logarithmic value Z. In this operation, the logarithmic calculator 62 acquires a logarithmic value “log2(1+X1/223)” as a mantissa part of the input value X from a logarithmic mantissa table storage unit 63 using an index index1 determined from the mantissa X1 and substitutes the logarithmic value log2(1+X1/223) in equation (6). The index index1 is used to identify a logarithmic value as a mantissa part of the input value X for the mantissa X1.
The logarithmic mantissa table storage unit 63 stores a logarithmic mantissa table listing logarithmic values of the mantissa part of the input value X with respect to the mantissa X1. An integer/fraction splitter 64 splits the logarithmic value Z from the logarithmic calculator 62 into an integer Zint and a fraction Zamari.
A power calculator 65 calculates the above-described equation (7) using the integer Zint and the fraction Zamari, from the integer/fraction splitter 64, thereby acquiring an arithmetic value P as floating-point type data. In this operation, the power calculator 65 acquires a power value 2^Zamari having base 2 with a power exponent of the fraction Zamari using index index2 determined from the fraction Zamari, and substitutes the power value 2^Zamari in equation (7). The index index2 is used to identify a power value as a power of 2 with respect to the fraction Zamari.
The symbol “^” denotes a power operation in the power value 2^Zamari, and the same is true in the discussion that follows. In other words, 2^Zamari means 2 to the power of Zamari.
A power of fraction table storage unit 66 stores a power of fraction table listing power values having base 2 with respect to the value the fraction Zamari. An integer converter 67 extracts an integer part of a number that results from adding a predetermined constant value α to the arithmetic value P determined by the power calculator 65. The integer converter 67 outputs the extracted integer part as a quantized value RZ of the input value X. In this case, the constant α is “−0.0946+0.5” in equation (1).
A quantization process of the quantizing apparatus 51 is discussed with reference to a flowchart illustrated in FIG. 4.
In step S11, the logarithmic mantissa table storage unit 63 and the power of fraction table storage unit 66 respectively generate a logarithmic mantissa table and a power of fraction table.
The logarithmic mantissa table storage unit 63 generates the logarithmic mantissa table composed of logarithmic values logtable[i] of the mantissa part of the input value X represented by equation (8) with a table size of the logarithmic mantissa table being 2N=SIZE:logtable[i]=log2(1+i/SIZE), i=0, . . . , SIZE−1  (8)where the table size SIZE is a count of numbers represented by data of N bits. The logarithmic values logtable[i] are prepared for the count of the table size SIZE. A variable “i” of the logarithmic values logtable[i] indicates the value of the index index1 determined from the mantissa X1, and is i=0, . . . , (SIZE−1).
With 2N=SIZE representing the table size of the power of fraction table, the power of fraction table storage unit 66 generates the power of fraction table composed of a power value twotable[i] having base 2 with the fraction Zamari as a power exponent as represented by equation (9)twotable[i]=2(i/SIZE), i=0, . . . , SIZE−1  (9)where the variable “i” of the power value twotable[i] indicates the value of index index2 determined from the fraction Zamari and is i=0, . . . , (SIZE−1).
In step S12, the mantissa/exponent splitter 61 determines the mantissa X1 and the exponent X2 of the supplied input value X.
In step S13, the logarithmic calculator 62 calculates equation (6) using the mantissa X1 and the exponent X2 from the mantissa/exponent splitter 61, thereby determining the logarithmic value Z.
More specifically, the logarithmic calculator 62 calculates equation (10) using the mantissa X1, thereby determining as the index index1 as the value of upper N bits from the 22nd bit of the mantissa X1. Using the index index1, the logarithmic calculator 62 further determines the logarithmic value logtable[index1] as the mantissa part of the input value X in accordance with the following equation (11):index1=X1>>(23−N)  (10)log2(1+X1/223)=logtable[index1]  (11)
In equation (10), “>>” denotes a right-shift operation. Since the mantissa X1 is 32 bits, the value of the upper N bits of the mantissa X1 can be extracted if the mantissa X1 is right-shifted by (23−N) bits.
The logarithmic calculator 62 acquires the logarithmic value logtable[index1] from the logarithmic mantissa table storage unit 63. The logarithmic value logtable[index1] has as a variable i the index index1 with the value of the upper N bits extracted from the mantissa X1 being the index index1. The acquired logarithmic value logtable[index1] is the logarithmic value (log2(1+X1/223)) of the mantissa part of the input value X.
The logarithmic calculator 62 substitutes the exponent X2 from the mantissa/exponent splitter 61, the supplied power exponent Y, and the determined arithmetic value into equation (6), thereby determining the logarithmic value Z.
In step S14, the integer/fraction splitter 64 splits the logarithmic value Z from the logarithmic calculator 62 into the integer Zint and the fraction Zamari. More specifically, the integer/fraction splitter 64 calculates the following equations (12) and (13), thereby determining the integer Zint and the fraction Zamari:
                              Z          int                =                  {                                                                                          (                    int                    )                                    ⁢                  Z                                                                              Z                  ≥                  0                                                                                                                                                (                      int                      )                                        ⁢                    Z                                    -                  1                                                                              Z                  <                  0                                                                                        (        12        )                                          Z          amari                =                              (            int            )                    ⁢                      (                                          (                                  Z                  -                                                            (                      int                      )                                        ⁢                    Z                                                  )                            ×                              2                23                                      )                                              (        13        )            
If the logarithmic value Z is equal to or greater than zero in equation (12), the integer part of the logarithmic value Z is extracted and treated as the integer Zint. If the logarithmic value Z is smaller than zero, the integer part of the logarithmic value Z is extracted and 1 is subtracted from the extracted integer part. The resulting value is treated as the integer Zint.
In equation (13), a value (difference) resulting from subtracting the integer part of the logarithmic value Z from the logarithmic value Z is multiplied by 223. The integer part of the resulting product is the fraction Zamari. In other words, the fraction part of the logarithmic value Z is calculated by determining a difference between the logarithmic value Z and the integer part of the logarithmic value Z. The fraction part is multiplied by 223, and the integer part of the resulting product is thus extracted. The fraction part of the logarithmic value Z is thus converted into a fixed-point number with the decimal point placed at the 23rd bit.
In step S15, the power calculator 65 determines the arithmetic value P based on the integer Zint and the fraction Zamari from the integer/fraction splitter 64.
More specifically, by calculating equations (14) and (15), the power calculator 65 determines the index index2, and then determines the power value having base 2 (2^Zamari) using the index index2 in accordance with equation (16):index2′=Zamari>>(23−N)  (14)index2=index2′&(SIZE−1)  (15)2Zamari=twotable[index2]  (16)
Symbol “>>” in equation (14) denotes a right-shift operation, and symbol “&” in equation (15) denotes an AND gate operation.
The power calculator 65 extracts as an index index2′ the value of the upper bits of the fraction Zamari from a (23−N)-th bit of the fraction Zamari by right-shifting the fraction Zamari by (23−N) bits. The fraction Zamari is a fixed-point number with the decimal point at the 23rd bit in accordance with equation (13). If the fraction Zamari is right-shifted by (23−N) bits, the value of the upper bits from the (23−N)-th bit of the fraction part of the fraction Zamari is extracted.
The power calculator 65 determines the index index2 of N bits by AND gating the index index2′ thus calculated and (SIZE−1), and retrieves from of the power of fraction table of the power of fraction table storage unit 66 the power value twotable[index2] with the index index2 as a variable i thereof. The power value twotable [index2] thus retrieved is the power value 2^Zamari having base 2.
The power calculator 65 calculates equation (17) using the integer Zint from the integer/fraction splitter 64, thereby determining the power value 2^Zint having base 2 with the integer Zint being a power exponent:2Zint=(Zint+127)<<23  (17)where symbol “<<” denotes a left-shift operation. More specifically, the power calculator 65 adds the bias component “127” to the integer Zint in order to convert the power value (2^Zint) to data in the floating-point format defined in the IEEE754 Standard, and then left-shifts the sum by 23 bits. The left-shift operation is performed by 23 bits since the exponent part of the floating-point number is a portion of 30th bit to 23rd bit of the floating-point data.
The power value (2^Zamari) and the power value (2^Zint) are thus obtained. The power calculator 65 calculates equation (18) to determine the arithmetic value P.P=2Zamari×2Zint  (18)
In step S16, the integer converter 67 determines and outputs the quantized value RZ of the input value X using the arithmetic value P determined by the power calculator 65. The quantization process thus ends.
More specifically, the integer converter 67 calculates equation (19) based on the arithmetic value P and the predetermined constant α, thereby determining the quantized value RZ.RZ=(int)(P+α)  (19)
The quantizing apparatus 51 calculates the power value of the input value X and the quantized value RZ in this way.